#ifndef _ADC_H_
#define _ADC_H_

#include<sc95fx.h>

// PERIOD
#define PERIOD_3sys 0x10
#define PERIOD_6sys 0x14
#define PERIOD_16sys 0x18
#define PERIOD_32sys 0x1C

//VREFS
#define VREFS_VDD 0
#define VREFS_2048mV 1
#define VREFS_1024mV 2

//ADCx
#define ADC0 0
#define ADC1 1
#define ADC2 2
#define ADC3 3
#define ADC4 4
#define ADC5 5
#define ADC6 6
#define ADC7 7
#define ADC8 8
#define ADC9 9
#define ADC10 10
#define ADC11 11
#define ADC12 12
#define ADC13 13
#define ADC14 14
#define ADC15 15

// AINx
#define AIN(ADCx) BIT(ADCx)
#define AIN0 BIT(0)
#define AIN1 BIT(1)
#define AIN2 BIT(2)
#define AIN3 BIT(3)
#define AIN4 BIT(4)
#define AIN5 BIT(5)
#define AIN6 BIT(6)
#define AIN7 BIT(7)
#define AIN8 BIT(8)
#define AIN9 BIT(9)
#define AIN10 BIT(10)
#define AIN11 BIT(11)
#define AIN12 BIT(12)
#define AIN13 BIT(13)
#define AIN14 BIT(14)
#define AIN15 BIT(15)

void ADC_power(bool STATE);
void ADC_setAINs(uint16_t AINx, bool STATE);
void ADC_setPeriod(uint8_t PERIOD);
void ADC_setVref(uint8_t VREFS);
void ADC_init(uint16_t AINx, uint8_t PERIOD, uint8_t VREFS);
void ADC_deinit();
void ADC_select(uint8_t ADCx);
void ADC_begin();
uint16_t ADC_getVoltageSync(uint8_t ADCx);

#endif
